home *** CD-ROM | disk | FTP | other *** search
/ The Guided Tour of Multimedia (Second Edition) / The Guided Tour of Multimedia (Second Edition).iso / trials / qtw111 / inc / qtcodec.h < prev    next >
C/C++ Source or Header  |  1993-11-22  |  15KB  |  334 lines

  1.  
  2.  
  3. // ---------------------------------------------------------------------
  4. //
  5. // QTCODEC.H - QuickTime for Windows C and C++ Bindings
  6. //
  7. //             Version 1.1
  8. //
  9. //             (c) 1988-1993 Apple Computer, Inc. All Rights Reserved.
  10. //
  11. // ---------------------------------------------------------------------
  12.  
  13.  
  14. #if !defined __QTCODEC_H
  15. #define __QTCODEC_H
  16.  
  17. // Header files
  18. #include <qtw.h>
  19. #include <compmgr.h>
  20.  
  21. // Macros
  22. #define ADDOFFSET(a,b) (LPBYTE)((char _huge *)(a)+(b))
  23. #define SUBOFFSET(a,b) (LPBYTE)((char _huge *)(a)-(b))
  24. #define HUGESUM(a,b,c) ADDOFFSET(a,FIELDOFFSET(b,c))
  25. #define ROUNDUP(a,b) (((a)+(b-1))&(~(b-1)))
  26. #define ROUNDDOWN(a,b) ((a)&(~(b-1)))
  27. #define ROUNDDOWNSLOW(a,b) ((a)-((a)%(b)))
  28. #define LOCAL static _near
  29. #define GlobalDeref(a) GlobalLock(a)
  30.  
  31. // Data types
  32. typedef short * PSHORT ;
  33. typedef short FAR * LPSHORT ;
  34. typedef BOOL * PBOOL ;
  35. typedef BOOL FAR * LPBOOL ;
  36. #define HUGE _huge
  37. typedef char HUGE * HPSTR ;
  38. typedef unsigned char HUGE * HPBYTE ;
  39. typedef void HUGE * HPVOID ;
  40. typedef LONG HUGE * HPLONG ;
  41. typedef VOID ( FAR CDECL * HDWDISP)( ...) ;
  42.  
  43. // Data
  44. enum OPT_TYPE { OPT_UNINIT = 0              // field uninitialized
  45.               , OPT_RAW    = 1              // decompress to raw buffer
  46.               , OPT_BMP    = 2              // decompress to BMP
  47.               , OPT_HDW    = 3              // decompress to video adapter
  48.               } ;
  49. enum BMP_TYPE { BMP_NONE      =  0          // unknown type
  50.               , BMP_DIB       =  1          // DIB
  51.               , BMP_MONO      =  2          // monochrome
  52.               , BMP_PACKED_4  =  3          // packed 4 bit, e.g., Fahrenheit
  53.               , BMP_PLANAR_4  =  4          // VGA or SVGA
  54.               , BMP_INDEX_8   =  5          // palettized driver
  55.               , BMP_5_5_5     =  6          // 32,768 colors
  56.               , BMP_5_6_5     =  7          // XGA, Intel order
  57.               , BMP_PLANAR_16 =  8          // two planes of one byte each
  58.               , BMP_8_8_8_RGB =  9          // true color RGB
  59.               , BMP_MEMERR    = 10          // insufficient memory for buffers
  60.               , BMP_8_8_8_BGR = 11          // true color BGR
  61.               , BMP_5_6_5_M   = 12          // XGA, Motorola order
  62.               } ;
  63. typedef LONG ImageSequence ;
  64. // We regard as a limiting case a 1,600 x 1,200 screen with 3 bytes
  65. // per pixel and a pixel pitch that is a power of 2, thus 8,192.
  66. // This gives a bank break every 8 lines, for a total of 150 bank
  67. // breaks.
  68. #define MAXBANKBREAKS 150
  69. #if !defined _MATRIX
  70. #define _MATRIX
  71. typedef LONG LFRACT ;
  72. #define MAKELFRACT(value, fract) ((((DWORD)(fract))>>2) | (((DWORD)((WORD)(value))) << 30))
  73. typedef struct {                            // Hungarian: mtrx
  74.   struct {
  75.     LFIXED lfxCol1 ;
  76.     LFIXED lfxCol2 ;
  77.     LFRACT lfrCol3 ;
  78.   } Row[ 3] ;
  79. } MATRIX, FAR * LPMATRIX ;
  80. #endif                                      // !defined _MATRIX
  81. #define ostypeAPPL  QTFOURCC( 'a', 'p', 'p', 'l')
  82. #define ostypeCVID  QTFOURCC( 'c', 'v', 'i', 'd')
  83. #define ostypeDCMP  QTFOURCC( 'd', 'c', 'm', 'p')
  84. #define ostypeJPEG  QTFOURCC( 'j', 'p', 'e', 'g')
  85. #define ostypeRAW   QTFOURCC( 'r', 'a', 'w', ' ')
  86. #define ostypeRLE   QTFOURCC( 'r', 'l', 'e', ' ')
  87. #define ostypeRPZA  QTFOURCC( 'r', 'p', 'z', 'a')
  88. #define ostypeRT21  QTFOURCC( 'r', 't', '2', '1')
  89. #define ostypeSMC   QTFOURCC( 's', 'm', 'c', ' ')
  90.  
  91. /* Codec function selectors
  92.    Codec selectors 0-127 are reserved by Apple
  93.    Codec selectors 128-191 are subtype specific
  94.    Codec selectors 192-255 are vendor specific
  95.    Codec selectors 256-32767 are reserved by Apple
  96.    Negative selectors are reserved by the Component Manager
  97. */
  98. enum CODEC_SELECTOR { codecGetCodecInfo           =  0
  99.                     , codecGetCompressionTime     =  1
  100.                     , codecGetMaxCompressionSize  =  2
  101.                     , codecPreCompress            =  3
  102.                     , codecBandCompress           =  4
  103.                     , codecPreDecompress          =  5
  104.                     , codecBandDecompress         =  6
  105.                     , codecCDSequenceBusy         =  7
  106.                     , codecGetCompressedImageSize =  8
  107.                     , codecGetSimilarity          =  9
  108.                     , codecTrimImage              = 10
  109.                     } ;
  110.  
  111. typedef struct tagCODECCAPABILITIES {
  112.   LONG     lFlags ;
  113.   WORD     wWantedPixelSize ;
  114.   WORD     wExtendWidth ;                   // extra bytes after last row
  115.   WORD     wExtendHeight ;                  // number of rows per compress unit
  116.   WORD     wBandMin ;
  117.   WORD     wBandInc ;
  118.   WORD     wPad ;
  119.   WORD     wTime ;
  120.                                             // new fields for Windows version
  121.   OPT_TYPE optt ;                           // the supported optimization
  122. } CODECCAPABILITIES, FAR * LPCODECCAPABILITIES ;
  123.  
  124. typedef struct tagMASKBITS  {
  125.   LPVOID lpBits ;                           // pointer to the bits
  126.   WORD wRowBytes ;                          // pixel pitch or BMP pitch
  127.   RECT rectBounds ;                         // clip rectangle
  128. } MASKBITS, FAR * LPMASKBITS ;
  129.  
  130. // flags for lFlags in CODECCAPABILITIES
  131. #define codecCanScale             (1L <<  0)
  132. #define codecCanMask              (1L <<  1)
  133. #define codecCanMatte             (1L <<  2)
  134. #define codecCanTransform         (1L <<  3)
  135. #define codecCanTransferMode      (1L <<  4)
  136. #define codecCanCopyPrev          (1L <<  5)
  137. #define codecCanSpool             (1L <<  6)
  138. #define codecCanClipVertical      (1L <<  7)
  139. #define codecCanClipRectangular   (1L <<  8)
  140. #define codecCanRemapColor        (1L <<  9)
  141. #define codecCanFastDither        (1L << 10)
  142. #define codecCanSrcExtract        (1L << 11)
  143. #define codecCanCopyPrevComp      (1L << 12)
  144. #define codecCanAsync             (1L << 13)
  145. #define codecCanMakeMask          (1L << 14)
  146. #define codecCanShift             (1L << 15)
  147.  
  148. // flags for lConditionFlags in CODECDECOMPRESSPARAMETERS
  149. #define codecConditionFirstBand         (1L <<  0)
  150. #define codecConditionLastBand          (1L <<  1)
  151. #define codecConditionCatchUp           (1L <<  2)
  152. #define codecConditionCodecChangedMask  (1L << 31)
  153.  
  154. typedef struct tagCODECDECOMPRESSPARAMS {
  155.   LONG lSequenceID ;                        // number of first frame
  156.   ImageDescription FAR * lpim ;             // pointer to image description
  157.   LPVOID lpCompressed ;                     // pointer to compressed data
  158.   LONG lBufferSize ;                        // no image buffer size
  159.   LONG lFrameNumber ;                       // within the sequence
  160.   LONG lStartLine ;                         // starting line of band
  161.   LONG lStopLine ;                          // ending line of band
  162.   LONG lConditionFlags ;                    // how component has been called
  163.   LONG lCallerFlags ;                       // further control information
  164.   LPCODECCAPABILITIES lpCapabilities ;      // filled out by PreDecompress
  165.   LPVOID lpvProgressProc ;                  // no progress proc
  166.   LPVOID lpvCompletionProc ;                // no completion proc
  167.   LPVOID lpvDataProc ;                      // no data loading proc
  168.   HDC hdc ;                                 // instead of CGrafPtr
  169.   LPVOID lpUncompressed ;                   // pointer to offscreen buffer
  170.   LPMASKBITS lpMaskBits ;                   // mask bits structure
  171.   LPVOID lpMattePixMap ;                    // blend matte (unused)
  172.   RECT rectSample ;                         // subset of sample to decompress
  173.   LPMATRIX lpMatrix ;                       // target transformation matrix
  174.   BYTE bAccuracy ;                          // requested accuracy
  175.   BYTE bAlign ;                             // for alignment only
  176.   WORD wRop2 ;                              // usually R2_COPYPEN
  177.   WORD wMatrixType ;                        // identify 0.5X, 2X, 4X
  178.   RECT rectDest ;                           // destination rectangle
  179.   // new fields for Windows version
  180.   LONG lCompressedSize ;                    // size of compressed data
  181.   BMP_TYPE bmpt ;                           // BMP type
  182.   LPVOID lpDitherTable ;                    // pointer to dither table
  183.   WORD wClutSeed ;                          // track CLUT changes
  184.   OPT_TYPE optt ;                           // optimization type
  185.   HDWDISP lpvHardware ;                     // addr of adapter dispatch routine
  186.   LPWORD lpwBankBoundaries ;                // adapter's bank boundary table
  187.   LPWORD lpwBitSmear ;                      // bit smearing table
  188.   WORD wRowsPerFullSegment ;                // banding will obsolete this
  189.   LPVOID lpOffScreen ;                      // offscreen handling of bank splits
  190.   DWORD dwReserved[ 1] ;                    // room for expansion
  191. }  CODECDECOMPRESSPARAMS, FAR * LPCODECDECOMPRESSPARAMS ;
  192.  
  193. typedef struct tagCODECINFO {
  194.   char szTypeName[ 32] ;                    // name of codec type
  195.   WORD wVersion ;
  196.   WORD wRevLevel ;
  197.   DWORD dwVendor ;
  198.   DWORD dwDecompressFlags ;
  199.   DWORD dwCompressFlags ;
  200.   DWORD dwFormatFlags ;
  201.   BYTE bDecompressionAccuracy ;
  202.   WORD wCompressionSpeed ;
  203.   WORD wDecompressionSpeed ;
  204.   BYTE bCompressionLevel ;
  205.   BYTE bReserved ;
  206.   WORD wMinimumHeight ;
  207.   WORD wMinimumWidth ;
  208.   WORD wDecompressPipelineLatency ;
  209.   WORD wCompressPipelineLatency ;
  210.   DWORD dwPrivateData ;
  211. }  CODECINFO, FAR * LPCODECINFO ;
  212.  
  213. // flags for dwComponentFlags in ComponentDescription structure
  214. // flags for dwDecompressFlags and dwCompressFlags in CODECINFO
  215. // The depths refer to target depths supported.
  216. #define codecInfoDoes1           (1L <<  0)
  217. #define codecInfoDoes4           (1L <<  1)
  218. #define codecInfoDoes8           (1L <<  2)
  219. #define codecInfoDoes16          (1L <<  3)
  220. #define codecInfoDoes24          (1L <<  4)
  221. #define codecInfoDoes32          (1L <<  5)
  222. #define codecInfoDoesDither      (1L <<  6)
  223. #define codecInfoDoesStretch     (1L <<  7)
  224. #define codecInfoDoesShrink      (1L <<  8)
  225. #define codecInfoDoesMask        (1L <<  9)
  226. #define codecInfoDoesTemporal    (1L << 10)
  227. #define codecInfoDoesDouble      (1L << 11)
  228. #define codecInfoDoesQuad        (1L << 12)
  229. #define codecInfoDoesHalf        (1L << 13)
  230. #define codecInfoDoesQuarter     (1L << 14)
  231. #define codecInfoDoesRotate      (1L << 15)
  232. #define codecInfoDoesHorizFlip   (1L << 16)
  233. #define codecInfoDoesVertFlip    (1L << 17)
  234. #define codecInfoDoesSkew        (1L << 18)
  235. #define codecInfoDoesBlend       (1L << 19)
  236. #define codecInfoDoesWarp        (1L << 20)
  237. #define codecInfoDoesRecompress  (1L << 21)
  238. #define codecInfoDoesSpool       (1L << 22)
  239.  
  240. // flags for dwFormatFlags in CODECINFO
  241. // The depths refer to source depths supported.
  242. #define codecInfoDepth1          (1L <<  0)
  243. #define codecInfoDepth2          (1L <<  1)
  244. #define codecInfoDepth4          (1L <<  2)
  245. #define codecInfoDepth8          (1L <<  3)
  246. #define codecInfoDepth16         (1L <<  4)
  247. #define codecInfoDepth24         (1L <<  5)
  248. #define codecInfoDepth32         (1L <<  6)
  249. #define codecInfoDepth33         (1L <<  7)
  250. #define codecInfoDepth34         (1L <<  8)
  251. #define codecInfoDepth36         (1L <<  9)
  252. #define codecInfoDepth40         (1L << 10)
  253. #define codecInfoStoresClut      (1L << 11)
  254. #define codecInfoDoesLossless    (1L << 12)
  255. #define codecInfoSeqSensitive    (1L << 13)
  256.  
  257. // Functions
  258. #if defined __cplusplus
  259. extern "C" {
  260. #endif
  261. ComponentResult QTAPI cfBandDecompress( STKOFF_CMP so
  262.                                       , LPVOID lpvStorage
  263.                                       , LPCODECDECOMPRESSPARAMS lpdecomp
  264.                                       ) ;
  265. ComponentResult QTAPI cfCanDoSelect( STKOFF_CMP so, LONG lFunctionSelector) ;
  266. ComponentResult QTAPI cfCloseSelect( STKOFF_CMP so, ComponentInstance ci) ;
  267. ComponentResult QTAPI cfGetCodecInfo( STKOFF_CMP so
  268.                                     , LPVOID lpvStorage
  269.                                     , LPCODECINFO lpinfo
  270.                                     ) ;
  271. ComponentResult QTAPI cfOpenSelect( STKOFF_CMP so, ComponentInstance ci) ;
  272. ComponentResult QTAPI cfPreDecompress( STKOFF_CMP so
  273.                                      , LPVOID lpvStorage
  274.                                      , LPCODECDECOMPRESSPARAMS lpdecomp
  275.                                      ) ;
  276. ComponentResult QTAPI cfRegisterSelect( STKOFF_CMP so, ComponentInstance ci) ;
  277. ComponentResult QTAPI cfSequenceBusy( STKOFF_CMP so
  278.                                     , LPVOID lpvStorage
  279.                                     , ImageSequence seq
  280.                                     ) ;
  281. ComponentResult QTAPI cfTargetSelect( STKOFF_CMP so, ComponentInstance ci) ;
  282. ComponentResult QTAPI cfVersionSelect( STKOFF_CMP so, ComponentInstance ci) ;
  283. DWORD QTAPI CodecEntry( VOID) ;
  284. VOID QTAPI CopyMemory( HPVOID hpvDest, HPVOID hpvSource, LONG cbCopy) ;
  285. WORD QTAPI Flip16( WORD wValue) ;
  286. VOID QTAPI Flip16Many( LPVOID lpSource, DWORD dwNbrWords) ;
  287. LONG QTAPI Flip32( LONG lValue) ;
  288. VOID QTAPI Flip32Many( LPVOID lpSource, DWORD dwNbrDwords) ;
  289. BOOL QTAPI FreeMemory( LPVOID lpvMem) ;
  290. LPVOID QTAPI GetMemory( LONG lSize) ;
  291. LPVOID QTAPI ReallocateMemory( LPVOID lpvMem, LONG lSize) ;
  292. OSType FAR PASCAL THNGIDENTIFY( LPCID FAR *lplpcid) ;
  293. VOID QTAPI VidComputeBankBoundaries1( LPWORD lpSourceTable
  294.                                     , LPWORD lpTargetTable
  295.                                     , WORD wLeft
  296.                                     , WORD wTop
  297.                                     , WORD wRight
  298.                                     , WORD wBottom
  299.                                     ) ;
  300. VOID QTAPI VidComputeBankBoundaries2( LPWORD lpSourceTable
  301.                                     , LPWORD lpTargetTable
  302.                                     , WORD wLeft
  303.                                     , WORD wTop
  304.                                     , WORD wRight
  305.                                     , WORD wBottom
  306.                                     ) ;
  307. VOID QTAPI VidComputeBankBoundaries4( LPWORD lpSourceTable
  308.                                     , LPWORD lpTargetTable
  309.                                     , WORD wLeft
  310.                                     , WORD wTop
  311.                                     , WORD wRight
  312.                                     , WORD wBottom
  313.                                     ) ;
  314. VOID QTAPI VidComputeBankBoundaries81( LPWORD lpSourceTable
  315.                                      , LPWORD lpTargetTable
  316.                                      , WORD wLeft
  317.                                      , WORD wTop
  318.                                      , WORD wRight
  319.                                      , WORD wBottom
  320.                                      ) ;
  321. VOID QTAPI VidComputeBankBoundaries82( LPWORD lpSourceTable
  322.                                      , LPWORD lpTargetTable
  323.                                      , WORD wLeft
  324.                                      , WORD wTop
  325.                                      , WORD wRight
  326.                                      , WORD wBottom
  327.                                      ) ;
  328. BMP_TYPE QTAPI VidGetBMPType() ;
  329. #if defined __cplusplus
  330. }                                           // defined __cplusplus
  331. #endif
  332.  
  333. #endif                                      // !defined __QTCODEC_H
  334.